<section class="title">
	<?php if ($this->controller == 'admin_categories' && $this->method === 'edit'): ?>
	<h4><?php echo sprintf(lang('escort_ads_zone_edit_title'), $zone->zone);?></h4>
	<?php else: ?>
	<h4><?php echo lang('escort_ads_zone_create_title');?></h4>
	<?php endif; ?>
</section>

<section class="item">
<?php echo form_open($this->uri->uri_string(), 'class="crud" id="zones"'); ?>

<div class="form_inputs">

	<ul>
		<li class="even">
		<label for="zone"><?php echo lang('escort_ads_zone_zone_label');?> <span>*</span></label>
		<div class="input">
			<?php echo  form_input('zone', $zone->zone); ?>
		</div>
		</li>
		<li>
			<label for="code"><?php echo lang('escort_ads_zone_code_label');?> <span>*</span></label>
			<div class="input">
			<?php echo  form_input('code', $zone->code); ?>
			</div>
		</li>
		<li>
			<label for="width"><?php echo lang('escort_ads_zone_width_label');?> <span>*</span></label>
			<div class="input">
			<?php echo  form_input('width', $zone->width); ?><span><?php  echo lang('escort_ads_zone_px_label')?></span>
			</div>
		</li>
		<li>
			<label for="height"><?php echo lang('escort_ads_zone_height_label');?> <span>*</span></label>
			<div class="input">
			<?php echo  form_input('height', $zone->height); ?><span><?php  echo lang('escort_ads_zone_px_label')?></span>
			</div>
		</li>
		<li>
			<label for="height"><?php echo lang('escort_ads_zone_domain_label');?> <span>*</span></label>
			<div class="input">
			<?php
				if($sites){
					$siteIds = $zone->site_ids;
					$siteIdsArray = array();
					if(strpos($siteIds, ',')){
						$tok = strtok($siteIds, ",");
						while ($tok !== false) {
							$siteIdsArray[] = $tok; 
							$tok = strtok(",");
						}
					}else{
						$siteIdsArray[] = $siteIds;
					}
					foreach ($sites as $site){
						$checked = false;
						foreach ($siteIdsArray as $siteId){
							if($site->id == $siteId){
								$checked = true;
								break;
							}
						}
			?>
				<?php echo form_checkbox('site_ids[]', $site->id, $checked, 'class="escort-checkbox"') ?><span><?php echo $site->domain;?></span>
			<?php
					}
				} 
			?>
			</div>
		</li>
	</ul>
	
</div>

	<div><?php $this->load->view('admin/partials/buttons', array('buttons' => array('save', 'cancel') )); ?></div>

<?php echo form_close(); ?>
</section>